import { ApiProperty } from '@nestjs/swagger';
import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  ManyToOne,
  // OneToOne,
  // OneToMany,
} from 'typeorm';
import { ExamEntity } from '../exam/exam.entity';

@Entity()
export class Question {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column()
  @ApiProperty({ type: 'string', example: '请问1+1等于几' })
  title: string;

  @Column()
  @ApiProperty({ type: 'string', example: '2' })
  answer: string;

  @ManyToOne(() => ExamEntity, (exam) => exam.questions)
  exam: ExamEntity;
  // @OneToMany(() => Article, (article) => article.category)
  // articles: Array<Article>;
  @CreateDateColumn({
    type: 'datetime',
    comment: '创建时间',
    name: 'create_at',
  })
  createAt: Date;

  @UpdateDateColumn({
    type: 'datetime',
    comment: '更新时间',
    name: 'update_at',
  })
  updateAt: Date;
}
